package com.fr.dialog.core;

import com.fr.base.DefaultValues;
import com.fr.base.FRContext;
import com.fr.base.Inter;
import com.fr.base.core.GraphHelper;
import com.fr.cell.core.GUICoreUtils;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JComboBox;
import javax.swing.JList;

public class LineComboBox extends JComboBox
{
  public LineComboBox(int[] paramArrayOfInt)
  {
    Integer[] arrayOfInteger = new Integer[paramArrayOfInt.length];
    for (int i = 0; i < paramArrayOfInt.length; ++i)
      arrayOfInteger[i] = new Integer(paramArrayOfInt[i]);
    setModel(new DefaultComboBoxModel(arrayOfInteger));
    setRenderer(new LineCellRenderer(this));
  }

  public int getSelectedLineStyle()
  {
    int i = ((Integer)getSelectedItem()).intValue();
    return ((i < 0) ? 0 : i);
  }

  public void setSelectedLineStyle(int paramInt)
  {
    GUICoreUtils.setSelectedItem(this, new Integer(paramInt));
  }

  class LineCellRenderer extends DefaultListCellRenderer
  {
    private int style;
    private boolean isSelected;
    private final LineComboBox this$0;

    LineCellRenderer()
    {
      this.this$0 = paramLineComboBox;
      this.style = 0;
      this.isSelected = false;
    }

    public Component getListCellRendererComponent(, Object paramObject, int paramInt, boolean paramBoolean1, boolean paramBoolean2)
    {
      this.style = ((Integer)paramObject).intValue();
      this.isSelected = paramBoolean1;
      return this;
    }

    public void paint()
    {
      Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
      Dimension localDimension = getSize();
      localGraphics2D.setColor(Color.black);
      localGraphics2D.setFont(FRContext.getDefaultValues().getFRFont());
      FontMetrics localFontMetrics = GraphHelper.getFontMetrics(FRContext.getDefaultValues().getFRFont());
      if (this.style == 0)
        GraphHelper.drawString(localGraphics2D, Inter.getLocText("None"), 4.0D, (localDimension.height - localFontMetrics.getHeight()) / 2 + localFontMetrics.getAscent());
      else
        GraphHelper.drawLine(localGraphics2D, 4.0D, localDimension.height / 2, localDimension.width - 8, localDimension.height / 2, this.style);
      if (this.isSelected)
      {
        localGraphics2D.setColor(Color.blue);
        GraphHelper.drawRect(localGraphics2D, 0.0D, 0.0D, localDimension.width - 1, localDimension.height - 1);
      }
    }

    public Dimension getPreferredSize()
    {
      return new Dimension(60, 16);
    }

    public Dimension getMinimumSize()
    {
      return getPreferredSize();
    }
  }
}